﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace XliffEditor
{
    public partial class MainForm : Qios.DevSuite.Components.Ribbon.QRibbonForm
    {
        public MainForm()
        {
            this.Font = SystemFonts.DialogFont;
            InitializeComponent();
            AdjustForm();
        }

        public void AdjustForm()
        {

            //Get desktop working area size
            Size availableFormSize = Screen.GetWorkingArea(this).Size;
            

            //Adjust Form size and location
            this.Size = availableFormSize;
            this.Location = new Point(0, 0);

            // set english and french flags for demo

            //Todo: Add business logic to change flags depending on language pair

            pbSource.Image = ListFlags.Images[23];
            pbTarget.Image = ListFlags.Images[6];
            //adjust splitter location to middle of form
            splTranslation.SplitterDistance = splTranslation.Width / 2;
            splTranslation.Panel1MinSize = 395;
            splTranslation.Panel2MinSize = 395;



        }

        private void ribbonOrbMenuItem7_Click(object sender, EventArgs e)
        {
            //Close form
            this.Close();
        }

        private void rbbAbout_Click(object sender, EventArgs e)
        {
            
            Form About = new NiceAboutBox();
            About.Show();
        }


        private void TuiPanelVisible(bool Show)
        //Shows Or Hides the Trans-unit Panel
        {
            pnlTUID.Visible = Show;
        }

     //Show or Hide the Search toolbar
        private void rbbSearchBar_Click(object sender, EventArgs e)
        {
            if (groupBox1.Visible == true && groupBox2.Visible == true)
                ShowToolbar(groupBox1, groupBox2, false);
            else
                ShowToolbar(groupBox1, groupBox2, true);
        }
        //Show or hide the Trans-Unit ID toolbar
        private void rbnTUID_Click(object sender, EventArgs e)
        {
            if (pnlTUID.Visible == true)
            {
                ShowToolbar(pnlTUID, false);

            }
            else
            {
                ShowToolbar(pnlTUID, true);
            }
        }

        //Show or Hide the Match toolbar
        private void rbbMatch_Click(object sender, EventArgs e)
        {
            if (pnlMatch.Visible == true)
                ShowToolbar(pnlMatch, false);
            else
                ShowToolbar(pnlMatch, true);
        }

        //Show or hide the toolbar 
        private void ShowToolbar(Control ToolbarName, bool Show)
        {
            if (ToolbarName.Visible == Show)
                return;
            else
                ToolbarName.Visible = Show;
        }

        //Show or hide the toolbar (allows for two toolbars)
        private void ShowToolbar(Control ToolbarName, Control ToolbarName2, bool Show)
        {
            if (ToolbarName.Visible == Show && ToolbarName2.Visible == Show)
                return;
            else
                ToolbarName.Visible = Show;
                ToolbarName2.Visible = Show;
        }

        //Show License information
        private void rbbLicense_Click(object sender, EventArgs e)
        {
            Thanks License = new Thanks();
            License.ShowDialog();
           
        }

        private void rbbQuickOpen_Click(object sender, EventArgs e)
        {
           openFileDialog1.DefaultExt = ".xlf";
            
        }

       




    }
}
